home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / MacTechNotes / Platforms & Tools / Stand-Alone Code Folder / PascalWDEFƒ / MyWindowDef.p < prev    next >
Encoding:
Text File  |  1990-07-24  |  1.9 KB  |  85 lines  |  [TEXT/MPS ]

  1. UNIT WDef;
  2.  
  3. INTERFACE
  4.  
  5.   USES MemTypes, QuickDraw, OSIntf, ToolIntf;
  6.  
  7. {this is the only external routine}
  8.   FUNCTION MyWindowDef(varCode: Integer; theWindow: WindowPtr; message: Integer;
  9.                        param: LongInt): LongInt; {As defined in IM p. I-299}
  10.  
  11. IMPLEMENTATION
  12.  
  13.   FUNCTION MyWindowDef(varCode: Integer; theWindow: WindowPtr; message: Integer;
  14.                        param: LongInt): LongInt;
  15.  
  16.     TYPE
  17.       RectPtr = ^Rect;
  18.  
  19.     VAR
  20.       aRectPtr : RectPtr;
  21.  
  22.   {here are the routines that are dispatched to by MyWindowDef}
  23.  
  24.     PROCEDURE DoDraw(theWind: WindowPtr; DrawParam: LongInt);
  25.       BEGIN {DoDraw}
  26.         {Fill in the code!}
  27.       END; {DoDraw}
  28.  
  29.     FUNCTION DoHit(theWind: WindowPtr; theParam: LongInt): LongInt;
  30.       BEGIN {DoHit}
  31.         {Code for this FUNCTION goes here}
  32.       END;    {DoHit}
  33.  
  34.     PROCEDURE DoCalcRgns(theWind: WindowPtr);
  35.       BEGIN {DoCalcRgns}
  36.         {Code for this PROCEDURE goes here}
  37.       END;    {DoCalcRgns}
  38.  
  39.     PROCEDURE DoGrow(theWind: WindowPtr; theGrowRect: Rect);
  40.       BEGIN {DoGrow}
  41.         {Code for this PROCEDURE goes here}
  42.       END;    {DoGrow}
  43.  
  44.     PROCEDURE DoDrawSize(theWind: WindowPtr);
  45.       BEGIN {DoDrawSize}
  46.         {Code for this PROCEDURE goes here}
  47.       END;    {DoDrawSize}
  48.  
  49.     {now for the main body to MyWindowDef}
  50.   BEGIN  { MyWindowDef }
  51.   {case out on the message and jump to the appropriate routine}
  52.     MyWindowDef := 0; {initialize the function result}
  53.  
  54.     CASE message OF
  55.  
  56.       wDraw:  { draw window frame}
  57.         DoDraw(theWindow,param);
  58.  
  59.       wHit:   { tell what region the mouse was pressed in}
  60.         MyWindowDef := DoHit(theWindow,param);
  61.  
  62.       wCalcRgns: { calculate structRgn and contRgn}
  63.         DoCalcRgns(theWindow);
  64.  
  65.       wNew:   { do any additional initialization}
  66.         { we don’t need to do any}
  67.         ;
  68.  
  69.       wDispose:{ do any additional disposal actions}
  70.         { we don’t need to do any}
  71.         ;
  72.  
  73.       wGrow:  { draw window’s grow image}
  74.         BEGIN
  75.           aRectPtr := RectPtr(param);
  76.           DoGrow(theWindow,aRectPtr^);
  77.         END; {CASE wGrow}
  78.  
  79.       wDrawGIcon:{ draw Size box in content region}
  80.         DoDrawSize(theWindow);
  81.  
  82.     END; {CASE}
  83.   END; {MyWindowDef}
  84. END. {of UNIT}
  85.